package puzzle
{
	import org.wak.action.IInteractable;
	import org.wak.character.AdventureCharacter;
	import org.wak.character.display.AnimationBehaviour;
	import org.wak.inventory.InventoryItem;
	import org.wak.main.PuzzleControllerBase;
	import org.wak.scene.ISceneInteractable;

	public class MyPuzzleController extends PuzzleControllerBase
	{
		private var mInteractionBehaviour:String = "" ;
		private var mChestLocked:Boolean = true ;
		
		public function MyPuzzleController()
		{
			super();
		}
		
		public function InteractASDoor( pItem:IInteractable ):void
		{
			trace("InteractASDoor");
			var fPlyrChar:AdventureCharacter = mCharactersMngr.GetPlayerCharacter() ;
			//mDialogMngr.SetOptionVisible("DFirstChat","TWhere",true);
			mDialogMngr.StartDialog("DTestChat");
			
			EndOfAction();
		}
		
		public function UseISwordAndIBag(pItemA:IInteractable,pItemB:IInteractable):void
		{
			trace("UseISwordAndIBag");
			EndOfAction();
		}
		
		public function UseISwordAndASDoor(pItemA:IInteractable,pItemB:IInteractable):void
		{
			var fSword:InventoryItem = mInventoryMngr.GetInventoryItem("ISword");
			var fBroken:InventoryItem = mInventoryMngr.GetInventoryItem("IBrokenSword");
			
			var fPlyrChar:AdventureCharacter = mCharactersMngr.GetPlayerCharacter() ;
			if( fPlyrChar.inventory.HasItem(fSword) )
			{
				fPlyrChar.inventory.RemoveItem(fSword);
				fPlyrChar.inventory.AddItem(fBroken);
				mDialogMngr.DisplayInfo("You broke sword.");
			}
			
			EndOfAction();
		}
		
	
		
		public function InteractSecondChar(pItem:ISceneInteractable):void
		{
			var fPlyrChar:AdventureCharacter = mCharactersMngr.GetPlayerCharacter() ;
			fPlyrChar.characterDisplay.SetAnimBehaviour( pItem.interactionBehaviour );
			mDialogMngr.StartDialog("DFirstChat");
			
			EndOfAction();
		}
		
		public function UseIBagAndYourHero(pItemA:IInteractable,pItemB:IInteractable):void
		{
			trace("UseIBagAndYourHero");
			mDialogMngr.DisplayInfo("You check if there is any fake coin.");
			EndOfAction();
		}
		
		public function GetSword():void
		{
			var fItem:InventoryItem = mInventoryMngr.GetInventoryItem("ISword");
			var fPlyrChar:AdventureCharacter = mCharactersMngr.GetPlayerCharacter() ;
			fPlyrChar.inventory.AddItem(fItem);
			mDialogMngr.DisplayInfo("You get a sword.");
		}
		
		public function UseIBrokenSwordAndSIChest(pItemA:IInteractable,pItemB:IInteractable):void
		{
			if( mChestLocked )
			{
				mDialogMngr.DisplayInfo("Now is unlocked.");
				mChestLocked = false ;
			}
			else
			{
				mDialogMngr.DisplayInfo("Is already open.");
			}
		}
		
		public function InteractSIChest(pItemA:IInteractable):void
		{
			if(mChestLocked)
			{
				var fPlyrChar:AdventureCharacter = mCharactersMngr.GetPlayerCharacter() ;
				fPlyrChar.Say("Is Locked.");
			}
			
			EndOfAction() ;
		}
		
		public function EnterSceneRoom(pSceneId:String):void
		{
			trace("office controller EnterScene: " + pSceneId );
		}
		
		
		
	}
	
}